<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">

		<title>地址管理</title>

		<link href="${ctxPath}/static/mall/AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet" type="text/css">
		<link href="${ctxPath}/static/mall/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css">

		<link href="${ctxPath}/static/mall/css/personal.css" rel="stylesheet" type="text/css">
		<link href="${ctxPath}/static/mall/css/addstyle.css" rel="stylesheet" type="text/css">
		<script src="${ctxPath}/static/mall/AmazeUI-2.4.2/assets/js/jquery.min.js" type="text/javascript"></script>
		<script src="${ctxPath}/static/mall/AmazeUI-2.4.2/assets/js/amazeui.js"></script>
		<script src="${ctxPath}/static/js/area.js"></script>
	</head>

	<body>
		<!--头 -->
		@layout("/mall/layout/mallHeader.html"){}
		<b class="line"></b>

		<div class="center">
			<div class="col-main">
				<div class="main-wrap">

					<div class="user-address">
						<!--标题 -->
						<div class="am-cf am-padding">
							<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">地址管理</strong> / <small>Address&nbsp;list</small></div>
						</div>
						<hr/>
						<ul class="am-avg-sm-1 am-avg-md-3 am-thumbnails">

						@for(address in page!){
						 @if(address.isDefault == '0'){
						<li class="user-addresslist"><span onclick="setDefault(${address.id!})"
							class="new-option-r"> <i class="am-icon-check-circle"></i>设为默认
						</span>
							<p class="new-tit new-p-re">
								<span class="new-txt">${address.trueName!}</span> <span
									class="new-txt-rd2">${address.telPhone!}</span>
							</p>
							<div class="new-mu_l2a new-p-re">
								<p class="new-mu_l2cw">
									<span class="title">地址：</span> <span class="province">${address.areaInfo!}</span>
									<span class="street">${address.address!}</span>
								</p>
							</div>
							<div class="new-addr-btn">
								<a href="#"><i class="am-icon-edit"></i>编辑</a> <span
									class="new-addr-bar">|</span> <a href="javascript:void(0);"
									onclick="delClick(this);"><i class="am-icon-trash"></i>删除</a>
							</div></li> 
							@}else{

						<li class="user-addresslist defaultAddr"><span
							class="new-option-r"> <i class="am-icon-check-circle"></i>默认地址
						</span>
							<p class="new-tit new-p-re">
								<span class="new-txt">${address.trueName!}</span> <span
									class="new-txt-rd2">${address.telPhone!}</span>
							</p>
							<div class="new-mu_l2a new-p-re">
								<p class="new-mu_l2cw">
									<span class="title">地址：</span> <span class="province">${address.areaInfo!}</span>
									<span class="street">${address.address!}</span>
								</p>
							</div>
							<div class="new-addr-btn">
								<a href="#"><i class="am-icon-edit"></i>编辑</a> <span
									class="new-addr-bar">|</span> <a href="javascript:void(0);"
									onclick="delClick(this);"><i class="am-icon-trash"></i>删除</a>
							</div></li>
							 @}
						 @}


					</ul>
						<div class="clear"></div>
						<a class="new-abtn-type" data-am-modal="{target: '#doc-modal-1', closeViaDimmer: 0}">添加新地址</a>
						<!--例子-->
						<div class="am-modal am-modal-no-btn" id="doc-modal-1">

							<div class="add-dress">

								<!--标题 -->
								<div class="am-cf am-padding">
									<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">新增地址</strong> / <small>Add&nbsp;address</small></div>
								</div>
								<hr/>

								<div class="am-u-md-12 am-u-lg-8" style="margin-top: 20px;">
									<form class="am-form am-form-horizontal" id="address_form" action="${ctxPath}/person/saveAddress" method="post">

										<div class="am-form-group">
											<label for="user-name" class="am-form-label">收货人</label>
											<div class="am-form-content">
												<input type="text" id="trueName" name="trueName" placeholder="收货人">
											</div>
										</div>

										<div class="am-form-group">
											<label for="user-phone" class="am-form-label">手机号码</label>
											<div class="am-form-content">
												<input id="telPhone" name="telPhone" placeholder="手机号必填" type="email">
											</div>
										</div>
										<div class="am-form-group">
											<label for="user-address" class="am-form-label">所在地</label>
											<div class="am-form-content address">
											<input id="city_id" type="hidden" name="cityId" value="">
									<input id="area_id" class="area_ids" type="hidden" name="areaId" value="">
									<input id="area_info" class="area_names" type="hidden" name="areaInfo" value="">
												<select name="area" class="select" id="area">
												<option value="o" >请选择。。。</option>
												@for(str in areas!){
													<option value="${str.id}" >${str.areaName}</option>
												@}	
												</select>
												 <span id="spancity"></span>
								    		<span id="spanqu"></span>
                                			<span class="areaMsg" style="color: red"></span>
												<!-- <select data-am-selected>
													<option value="a">温州市</option>
													<option value="b" selected>武汉市</option>
												</select>
												<select data-am-selected>
													<option value="a">瑞安区</option>
													<option value="b" selected>洪山区</option>
												</select> -->
											</div>
										</div>

										<div class="am-form-group">
											<label for="user-intro" class="am-form-label">详细地址</label>
											<div class="am-form-content">
												<textarea class="" name="address" rows="3" id="user-intro" placeholder="输入详细地址"></textarea>
												<small>100字以内写出你的详细地址...</small>
											</div>
										</div>

										<div class="am-form-group">
											<div class="am-u-sm-9 am-u-sm-push-3">
												<a class="am-btn am-btn-danger" onclick="saveAddress()" type="submit">保存</a>
												<a href="javascript: void(0)" class="am-close am-btn am-btn-danger" data-am-modal-close>取消</a>
											</div>
										</div>
									</form>
								</div>

							</div>

						</div>

					</div>

					<script type="text/javascript">
						$(document).ready(function() {							
							$(".new-option-r").click(function() {
								$(this).parent('.user-addresslist').addClass("defaultAddr").siblings().removeClass("defaultAddr");
							});
							
							var $ww = $(window).width();
							if($ww>640) {
								$("#doc-modal-1").removeClass("am-modal am-modal-no-btn")
							}
							
						})
					</script>

					<div class="clear"></div>

				</div>
				<!--底部-->
				@layout("/mall/layout/mallFooter.html"){}
		</div>
<script type="text/javascript">

function saveAddress(){
	$('#address_form').submit();
}
function setDefault(id){
	//var addressId = "address_"+id;
	$.ajax({
		type: "post",
 		url: '${ctxPath}/person/setAddressDef',
		data: {addressId:id},
		dataType: "json",
		success:function(data) {
			if(data.success){
				window.location.href = "${ctxPath!}/person/address";
		      //  obj.find("a").remove();
		       //	$("input[name='address_options']").attr("isDefault",0);
		      //  $("#"+addressId).attr("isDefault",1);
			}else{
				layer.msg("默认地址设置失败!",{icon:2});
			}
		}
	});
}
</script>
	</body>

</html>